package com.xq.dao;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xq.entity.TbUser;
import com.xq.vo.TbUserVo;
import com.xq.vo.TbloadUserVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @title: TbUserDao
 * @Author Tan
 * @Date: 2020/7/19 16:24
 * @Version 1.0
 */
@Repository
public interface TbUserDao extends BaseMapper<TbUser> {
    Page findByPageByDep(Page<TbUser> page, @Param(Constants.WRAPPER) QueryWrapper wrapper);

    @Update("update tb_user set status= #{status} where id=#{id}")
    Boolean updStatusById(@Param("id") Integer id,@Param("status") Integer status);

    @Select("select  uer.`id`, `username`, `nickname`, `email`, `phone_number`, `status`,  `sex`, `birth`,dep.`name` as name from tb_user uer\n" +
            "inner JOIN tb_department dep\n" +
            "on uer.department_id=dep.id ${ew.customSqlSegment}")
    List<TbloadUserVo> findAllDownload(@Param(Constants.WRAPPER) QueryWrapper wrapper);
}